Skip to content

Conversation

sorairolake
Copy link
Contributor

@sorairolake sorairolake commented Feb 10, 2025

Implement Random for tuples of arity 12 or less. Each element is expected to implement Random.

I think it's OK to implement this trait for the following types:

  • Primitive integer types and bool
  • Arrays and tuples of the above values
  • NonZero<T>, Saturating<T> and Wrapping<T>

The necessity of this trait is debated (#130703 (comment)), but if we decide to keep it in the future when the random module is stabilized, I think it would be useful to have this trait implemented for tuples.

Tracking issue: #130703

r? @joboet

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 10, 2025
@joboet
Copy link
Member

joboet commented Feb 20, 2025

The implementation looks reasonable to me, but this will need T-libs-api approval.

r? libs-api

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 20, 2025
@rustbot rustbot assigned joshtriplett and unassigned joboet Feb 20, 2025
@bors
Copy link
Collaborator

bors commented Mar 24, 2025

☔ The latest upstream changes (presumably #138873) made this pull request unmergeable. Please resolve the merge conflicts.

@sorairolake sorairolake force-pushed the add-random-for-tuple branch from b0098b7 to 8f97955 Compare March 24, 2025 05:12
@bors
Copy link
Collaborator

bors commented Apr 13, 2025

☔ The latest upstream changes (presumably #138881) made this pull request unmergeable. Please resolve the merge conflicts.

Implement `Random` for tuples of arity 12 or less. Each element is
expected to implement `Random`.
@sorairolake sorairolake force-pushed the add-random-for-tuple branch from 8f97955 to 07e8b28 Compare April 13, 2025 15:56
@joshtriplett
Copy link
Member

Seems reasonable given the current unstable trait. Whether we end up with this exact trait is another question, but this seems reasonable for unstable.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 1, 2025

📌 Commit 07e8b28 has been approved by joshtriplett

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 1, 2025
bors added a commit that referenced this pull request Jul 1, 2025
Rollup of 12 pull requests

Successful merges:

 - #136801 (Implement `Random` for tuple)
 - #141867 (Describe Future invariants more precisely)
 - #142760 (docs(fs): Touch up grammar on lock api)
 - #143181 (Improve testing and error messages for malformed attributes)
 - #143210 (`tests/ui`: A New Order [19/N] )
 - #143212 (`tests/ui`: A New Order [20/N])
 - #143230 ([COMPILETEST-UNTANGLE 2/N] Make some compiletest errors/warnings/help more visually obvious)
 - #143240 (Port `#[rustc_object_lifetime_default]` to the new attribute parsing …)
 - #143255 (Do not enable LLD by default in the dist profile)
 - #143262 (mir: Mark `Statement` and `BasicBlockData` as `#[non_exhaustive]`)
 - #143269 (bootstrap: make comment more clear)
 - #143279 (Remove `ItemKind::descr` method)

Failed merges:

 - #143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ad65039 into rust-lang:master Jul 1, 2025
6 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 1, 2025
rust-timer added a commit that referenced this pull request Jul 1, 2025
Rollup merge of #136801 - sorairolake:add-random-for-tuple, r=joshtriplett

Implement `Random` for tuple

Implement `Random` for tuples of arity 12 or less. Each element is expected to implement `Random`.

I think it's OK to implement this trait for the following types:

- Primitive integer types and `bool`
- Arrays and tuples of the above values
- ~~`NonZero<T>`~~, `Saturating<T>` and `Wrapping<T>`

The necessity of this trait is debated (<#130703 (comment)>), but if we decide to keep it in the future when the `random` module is stabilized, I think it would be useful to have this trait implemented for tuples.

Tracking issue: #130703

r? `@joboet`
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Jul 4, 2025
…r=joshtriplett

Implement `Random` for tuple

Implement `Random` for tuples of arity 12 or less. Each element is expected to implement `Random`.

I think it's OK to implement this trait for the following types:

- Primitive integer types and `bool`
- Arrays and tuples of the above values
- ~~`NonZero<T>`~~, `Saturating<T>` and `Wrapping<T>`

The necessity of this trait is debated (<rust-lang#130703 (comment)>), but if we decide to keep it in the future when the `random` module is stabilized, I think it would be useful to have this trait implemented for tuples.

Tracking issue: rust-lang#130703

r? `@joboet`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants